<template>
	<view class="page">
		<view class="infoImageListGroup">
			<view class="infoImageListTitle">
				<view class="infoImageListAddImgText">点击添加图片</view>
				<view class="infoImageListAddImgNum">{{ imageNumber }}/6</view>
			</view>
			<view class="infoImageList"><htz-image-upload :max="6" name="file" :chooseNum="6" :mediaType="image" v-model="imageData" @chooseSuccess="infoChooseSuccess" @imgDelete="infoImgDelete"></htz-image-upload></view>
			<view class="infoImageListContentGroup">
				<image src="../../static/icos/xinxi.png" mode="aspectFill" class="infoImageListContentIco"></image>
				<view class="infoImageListText">单击图片可以进行预览，右上角按钮进行删除</view>
			</view>
		</view>
		<view class="infoApace"></view>
		<block v-for="(infoSelectList, selectIndex) in selectList" :key="infoSelectList.ID">
			<view class="infoInputSelectGroup">
				<view class="infoSelect" @click="showDrawer('showRight' + infoSelectList.ID)">
					<view class="infoInputTitle">{{ infoSelectList.ClassName }}</view>
					<view class="infoSelectContent">
						<text>{{ infoSelectList.Sname }}</text>
						<span class="infoSelectContentMor">></span>
					</view>
				</view>
			</view>
			<!-- 右侧菜单开始 -->
			<template>
				<!-- <UniDrawer :ref="'showRight' + infoSelectList.ID" mode="right" :width="480" @change="change($event, 'showRight')"> -->
				<UniDrawer :ref="'showRight' + infoSelectList.ID" mode="right" :width="480">
					<view class="infoSelectScrollView">
						<scroll-view class="infoSelectScrollViewBox" scroll-y="true">
							<view class="infoSelectScrollContent" v-for="scrollItem in infoSelectList.data" :key="scrollItem.ID"  @click="closeDrawer('showRight' + infoSelectList.ID, selectIndex, scrollItem.ID, scrollItem.ClassName)">
								{{scrollItem.ClassName}}<view class="infoSelectScrollMore">></view>
							</view>
						</scroll-view>
					</view>
				</UniDrawer>
			</template>
			<!-- 右侧菜单结束 -->
			<view class="infoApace"></view>
		</block>
		<block v-for="(inputItemList, index) in inputList" :key="index">
			<template v-if="inputItemList.ClassName == '价格' || inputItemList.ClassName == '租金'" >
				<view class="infoInputSelectGroup">
					<view class="infoInput">
						<view class="infoInputTitle">面议</view>
						<view class="infoInputContent" style="">
							<input disabled="true" />
							<switch color="#c8000a" class="infoInputContentSwitch" @change="modifyNegotiable('DanWei1_ID' + inputItemList['ID'])" />
						</view>
					</view>
				</view>
				<view class="infoApace"></view>
				<view class="infoInputSelectGroup" v-show="!isNegotiable">
					<view class="infoInput">
						<view class="infoInputTitle">{{ inputItemList.ClassName }}</view>
						<view class="infoInputContent">
							<block v-for="(inputItem, key, index) in inputItemList" :key="index">
								<template v-if="key.startsWith('DanWei') && inputItemList[key] != ''">
									<input type="text" :name="key + '_ID' + inputItemList['ID']" :id="key + '_ID' + inputItemList['ID']" value="" placeholder="请输入" class="infoInputContentText" placeholder-class="infoPlaceholderStyle" @blur="onKeyInput" />
									<text class="infoInputContentUnit">{{ inputItemList[key] }}</text>
								</template>
							</block>
						</view>
					</view>
				</view>
				<view class="infoApace" v-show="!isNegotiable"></view>
			</template>
			<template v-else>
				<view class="infoInputSelectGroup">
					<view class="infoInput">
						<view class="infoInputTitle">{{ inputItemList.ClassName }}</view>
						<view class="infoInputContent">
							<block v-for="(inputItem, key, index) in inputItemList" :key="index">
								<template v-if="key.startsWith('DanWei') && inputItemList[key] != ''">
									<input type="text" :name="key + '_ID' + inputItemList['ID']" :id="key + '_ID' + inputItemList['ID']" value="" placeholder="请输入" class="infoInputContentText" placeholder-class="infoPlaceholderStyle" @blur="onKeyInput" />
									<text class="infoInputContentUnit">{{ inputItemList[key] }}</text>
								</template>
							</block>
						</view>
					</view>
				</view>
				<view class="infoApace"></view>
			</template>
		</block>
<!-- 		
		<template v-if="isShowindependentPrice">
			<view class="infoInputSelectGroup">
				<view class="infoInput">
					<view class="infoInputTitle">面议</view>
					<view class="infoInputContent" style="">
						<input disabled="true" />
						<switch color="#c8000a" class="infoInputContentSwitch" @change="modifyNegotiable" />
					</view>
				</view>
			</view>
			<view class="infoApace"></view>
			<view class="infoInputSelectGroup" v-show="!isNegotiable">
				<view class="infoInput">
					<view class="infoInputTitle">价格</view>
					<view class="infoInputContent">
						<input type="text" name="DanWei1ID0" id="DanWei1_ID0" value="" placeholder="请输入" class="infoInputContentText" placeholder-class="infoPlaceholderStyle" @blur="onKeyInput" />
						<text class="infoInputContentUnit">价格</text>
					</view>
				</view>
			</view>
			<view class="infoApace" v-show="!isNegotiable"></view>
		</template>
		 -->
		<view class="infoInputSelectGroup">
			<view class="infoAddress" @click="selectLocationAddress()">
				<view class="infoInputTitle">地址</view>
				<view class="infoAddressContent" >{{ addressContent }}</view>
				<image src="../../static/icos/xinxi.png" mode="aspectFill" class="infoAddressContentIco"></image>
			</view>
		</view>
		<view class="infoApace"></view>
		<view class="infoSparkleGroup" v-if="briefingTagList.length">
			<view class="infoSparkleTitle">亮点</view>
			<view class="infoSparkleContent">
				<view class="infoSparkleItem" :class=" briefingTagItem.isSelect ? 'infoSparkleItemRed': 'infoSparkleItemGrey'" @click="riefingTagSelect(briefingTagIndex)" v-for="(briefingTagItem, briefingTagIndex) in briefingTagList" :key="briefingTagItem.ID">{{ briefingTagItem.Name }}</view>
			</view>
		</view>
		<view class="infoApace" v-if="briefingTagList.length"></view>
		<view class="infoContentGroup">
			<view class="infoContentTitle">具体描述</view>
			<view class="infoContent"><textarea class="infoContentText" placeholder-class="infoPlaceholderStyle" :placeholder="infoContentText" v-model="infoContentDescribe" @blur="checkTextContent"/></view>
		</view>
		<view class="infoApace"></view>
		<view class="infoIsTopGroup" v-if="isShowPayment">
			<view class="infoIsTopText">
				置顶
				<text class="redtext">VIP</text>
				推广，在相应分类信息第一页显示，展现率更高，浏览更大
			</view>
			<view class="infoIsTop">
				<view class="infoIsTopTitle">置顶</view>
				<view>
					<radio-group name="" class="infoIsTopContent" @change="selectIsTopValue">
						<label class="infoIsTopItem" v-for="costItem in costList" :key="costItem.ID">
							<radio color="#c60209" class="infoIsTopItemRadio" :value="costItem.ID" :checked="costItem.ischecked == 'true'" />
							<text>{{ costItem.Title }}<text class="radioredtext">{{ costItem.Price }}元</text></text>
						</label>
					</radio-group>
				</view>
			</view>
		</view>
		<view class="infoApace" v-if="isShowPayment"></view>
		<view class="infoInputSelectGroup">
			<view class="infoInput">
				<view class="infoInputTitle">联系人</view>
				<view class="infoContactsContent">
					<input type="text" class="infoContactsContentInput" placeholder="输入联系人" placeholder-class="infoPlaceholderStyle" v-model="contacts"/>
				</view>
			</view>
		</view>
		<view class="infoApace" style="height: 2rpx;"></view>
		<view class="infoInputSelectGroup">
			<view class="infoInput">
				<view class="infoInputTitle">联系方式</view>
				<view class="infoContactsContent">
					<input type="text" class="infoContactsContentInput" placeholder="输入联系方式(座机请加区号)" placeholder-class="infoPlaceholderStyle" v-model="contactInfomation"/>
				</view>
			</view>
		</view>
		<view class="infoApace"></view>
		<view class="infoPaymentGroup" @click="isShowPaySelectContent()" v-if="isPayment">
			<view class="infoPaymentTitle">支付方式</view>
			<view class="infoPaymentContent">微信支付</view>
		</view>
		<view class="infoClauseGroup">
			<text class="infoClauseRed">*</text>
			<text class="infoClauseTextSize">发布条款</text>
			<checkbox-group @change="selectTerms">
				<checkbox class="infoClauseCheckbox" value="true" checked="true" color="#c60209" />
			</checkbox-group>
			<text class="infoClauseTextSize">已经阅读，并同意</text>
			<text class="infoClauseTextSize infoClauseRed infoClauseRedLine">发布须知</text>
		</view>
		<view><text class="infoTipsText">信息发布成功后，内容无法修改，请仔细核对</text></view>
		<view class="infoButton"><button type="default" @click="infoSubmit" class="infoSubmit">发布</button></view>
		<view class="bottom">
			<view class="infoPaymentSelect" v-show="isShowPaySelect">
				<view class="infoPaymentSelectContent">
					<view class="infoPaymentSelectImg"><image src="../../static/images/closed_red.png" mode="aspectFit" class="infoPaymentSelectClose" @click="isShowPaySelectContent()"></image></view>
					<view class="infoPaymentSelectTitle">请选择支付方式</view>
					<view class="infoPaymentSelectItemGroup">
						<view class="infoPaymentSelectItem">
							<image src="../../static/loginIco/qd.png" mode="aspectFit" class="infoPaymentSelectItemImg"></image>
							<text class="infoPaymentSelectItemText">余额 {{ userBalanceText }}</text>
						</view>
						<view class="infoPaymentSelectItem">
							<image src="../../static/loginIco/weixin.png" mode="aspectFit" class="infoPaymentSelectItemImg"></image>
							<text class="infoPaymentSelectItemText">微信支付</text>
						</view>
						<view class="infoPaymentSelectItemLarge" v-if="isShowPayMoneyDifference">
							<image src="../../static/loginIco/qd.png" mode="aspectFit" class="infoPaymentSelectItemImg"></image>
							<image src="../../static/loginIco/weixin.png" mode="aspectFit" class="infoPaymentSelectItemImg"></image>
							<text class="infoPaymentSelectItemText">微信支付补差价 {{ payPriceDifferenceText }}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 全局message组件 -->
		<QuickMessage ref="message"></QuickMessage>
	</view>
	
</template>

<script>
import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue';
import UniDrawer from '@/components/uni-drawer/uni-drawer.vue';
import QuickMessage from '@/components/quick-message/quick-message.vue';
import { moneyFormat } from '../../common/common.js';
export default {
	data() {
		return {
			isSubmit: true, // 是否可以提交信息 
			imageNumber: 0, // 上传临时图片个数
			imageData: [], // 上传图片列表
			inputList: [], //输入选项列表
			selectList: [], //选择项列表
			briefingTagList: [], //亮点列表
			costList: [], //费用列表
			infoContentText: '', //具体描述提示内容
			infoContentDescribe: '', //具体描述内容
			isNegotiable: false, //是否面议
			infoParams: {openid:getApp().globalData.openid, cid: getApp().globalData.cityId}, // 传递参数组合对象
			showRight: false, // 是否显示右侧滑动菜单
			selectHighlights: [], // 选中的亮点
			addressContent:'', // 获取当前位置物理地址
			longitude: null,	// 获取经度
			latitude: null,		//  获取维度
			isTopId: 0, // 置顶ID
			userBalanc:0, // 用户余额
			isShowPaySelect: false, //是否显示支付方式选择
			payments:0, // 需要支付金额
			payMoneyDifference:0, // 需要支付金额差价
			isShowPayment: true, // 是否显示置顶
			isPayment:true, // 是否需要支付
			paymentMethod:1, // 支付方式 0不需要支付，1默认微信支付，2微信补差价支付，3余额支付
			contacts:'', // 联系人
			contactInfomation:'', // 联系方式
			isTerms:true, // 是否同意条款
			unitsList:{
				ID0: {DanWei1: 'JiaGe'}, 
				ID2: {DanWei1: 'shi', DanWei2: 'ting', DanWei3: 'wei'}, 
				ID3: {DanWei1:'MianJie'}, 
				ID4: {DanWei1: 'JiaGe'}, 
				ID8: {DanWei1: 'shi', DanWei2: 'ting', DanWei3: 'wei'}, 
				ID10: {DanWei1: 'JiaGe'}, 
				ID12: {DanWei1:'MianJie'},
				ID15: {DanWei1:'MianJie'},
			}, // 单位
			isShowindependentPrice: false, //  在没有金额列表中是否只显示金额输入框
			
		};
	},
	async onLoad(res) {
		await this.$onLaunched;
		await this.getUserBalance()
		await this.getReleaseDetailed(res.Type, res.lmid)
		this.getLocation()
	},
	onShow() {
		this.UserInfoState = uni.getStorageSync('globalUserInfoState')
		// console.log(this.UserInfoState)
		console.log(uni.getStorageSync('globaUserInfo'))
		if(this.UserInfoState != 1) {
			this.$Reauthorization()
		}
	},
	methods: {
		confirm() {},
		// 打开窗口
		showDrawer(e) {
			this.$refs[e][0].open()
			// this.$nextTick(() => {
				//this.selectList.forEach((item, index) => {
					// this.$refs[e].open();
				//});
			// });
		},
		// 关闭窗口
		closeDrawer(e, index, id, name) {
			this.selectList[index].Sid = id
			this.selectList[index].Sname = name
			if(this.selectList.length == 1) {
				// 组合提交参数
				this.infoParams['xlid'] = id
				// this.infoParams['xlidName'] = name
			} else{
				// 组合提交参数
				this.infoParams['xlid'+(index+1)] = id
				// this.infoParams['xlid'+(index+1)+'Name'] = name
			}
			// console.log(this.infoParams)
			// console.log(this.selectList)
			this.$refs[e][0].close()
		},
		// 抽屉状态发生变化触发
		// change(e, type) {
		// 	console.log((type === 'showLeft' ? '左窗口' : '右窗口') + (e ? '打开' : '关闭'));
		// 	this[type] = e;
		// },
		infoChooseSuccess(tempFilePaths) {
			//选择图片返回
			// console.log('ceshiChooseSuccess', tempFilePaths)
			// this.imageData=this.imageData.concat(tempFilePaths)
			this.imageData.push(...tempFilePaths)
			this.imageNumber = this.imageData.length
			// console.log(this.imageData)
			/****************
				以下代码是自定义上传逻辑，仅供参考
			***************/
			this.infoImgReview(tempFilePaths)
			// this.infoImgUpload(tempFilePaths)
			/*******************************/
		},
		infoImgDelete(e) {
			// console.log(this.imageData)
			this.imageNumber = this.imageData.length
		},
		infoImgUpload(tempFilePaths) {
			uni.showLoading({
				title: '上传中'
			});
			console.log('imgUpload', tempFilePaths)
			let uploadImgs = [];
			tempFilePaths.forEach((item, index) => {
				uploadImgs.push(new Promise((resolve, reject) => {
					console.log(index, item)
					uni.uploadFile({
						url: "http://59.110.49.173:8001/api/common/uploadImg?dir=ad", //仅为示例，非真实的接口地址
						filePath: item,
						name: 'file',
						success: (uploadFileRes) => {
							console.log('uploadFileRes', uploadFileRes)
							resolve(uploadFileRes);
							var _res = JSON.parse(uploadFileRes.data);
							if (_res.code == 200) {
								// this.imageData.push('http://59.110.49.173:8001' + _res.result);
							}
						},
						fail: (err) => {
							console.log(err);
							reject(err);
						},
						complete: () => {
							// uni.hideLoading();
						}
					});
				}))
			})
			Promise.all(uploadImgs) //执行所有需请求的接口
				.then((results) => {
					uni.hideLoading();
				})
				.catch((res, object) => {
					uni.hideLoading();
				});
		},
		// 上传图片进行审核
		infoImgReview(tempFilePath){
			uni.showLoading({
				title: '上传中'
			});
			// console.log(tempFilePath[0])
			new Promise((resolve, reject) => {
				this.$api.uploadPictureReview({
					params: {}, /* 会加在url上 */
					// #ifdef APP-PLUS || H5
					// files: [], // 需要上传的文件列表。使用 files 时，filePath 和 name 不生效。App、H5（ 2.6.15+）
					// #endif
					
					// #ifdef MP-ALIPAY
					fileType: 'image/video/audio', // 仅支付宝小程序，且必填。
					// #endif
					
					filePath: tempFilePath[0], // 要上传文件资源的路径。
					name: 'file_img', // 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
					
					// #ifdef H5 || APP-PLUS
					timeout: 3000, // H5(HBuilderX 2.9.9+)、APP(HBuilderX 2.9.9+)
					// #endif
					
					// header: {}, /* 会与全局header合并，如有同名属性，局部覆盖全局 */
					// custom: {}, // 自定义参数
					// formData: {}, // HTTP 请求中其他额外的 form data
					// // 返回当前请求的task, options。请勿在此处修改options。非必填
					// getTask: (task, options) => {
					//   // setTimeout(() => {
					//   //   task.abort()
					//   // }, 500)
					// }
					
				}).then(res => {
					uni.hideLoading();
					if(res.errcode != 0) {
						// uni.showToast({
						// 	title:'图片违规',
						// 	icon:'error',
						// 	duration:2000,
						// })
						this.showMessage('error', '图片违规，自动删除', 'center')
						let imgIndex = this.imageData.indexOf(tempFilePath[0])
						this.imageData.splice(imgIndex, 1)
						this.imageNumber = this.imageData.length
					}
					// 
				})
			})
			
		},
		checkTextContent(e){
			// console.log(e)
			if(e.detail.value.length > 0) {
				this.$api.checkTextContent({filewz: e.detail.value}).then( res => {
					if(res.errcode != 0) {
						this.showMessage('error', '文字内容违规，请修改文字内容', 'center')
					}
				})
			}
		},
		getReleaseDetailed(type, lmid) {
			// 拼接提交参数
			this.infoParams['type'] = type
			this.infoParams['lmid'] = lmid
			this.infoParams['systype'] = ''
			this.$api.getReleaseDetailed({ type: type, lmid: lmid, systype: 'pc' }).then(res => {
				console.log(res);
				uni.setNavigationBarTitle({
					title: '发布' + res.data.LmName
				});
				this.inputList = res.data.TJLis;
				// this.selectList = res.data.XLList;
				// this.briefingTagList = res.data.LDList;
				if(res.data.IsFuFei == 1) {
				this.costList = res.data.FyList;
					for(let item of this.costList) {
						if(item.ischecked){
							//拼接参数支付ID
							this.infoParams['feeID'] = item.ID
							this.isTopId = item.ID
							this.payments = parseFloat(item.Price).toFixed(2)
							break
						}
					}
				} else {
					this.isShowPayment = false
					this.infoParams['feeID'] = 1
					this.isTopId = 1
				}
				this.infoContentText = res.data.Content;
				if(res.data.XLList){
					if(res.data.XLList.length > 1) {
						res.data.XLList.forEach((item, index) => {
							let tempitem = {...item, 'Sid': 0, 'Sname': '请选择分类'}
							this.selectList.push(tempitem)
							// 拼接参数
							this.infoParams['xlid'+(index+1)] = 0
							// this.infoParams['xlid'+(index+1)+'Name'] = '请选择分类'
						})
					} else {
						
						let tempitem = {...res.data.XLList[0], 'Sid': 0, 'Sname': '请选择分类'}
						this.selectList.push(tempitem)
						// 拼接参数
						this.infoParams['xlid'] = 0
						// this.infoParams['xlidName'] = '请选择分类'
					}
				}
				res.data.LDList.forEach((item, index) => {
					let tempitem = {...item, 'isSelect': false}
					this.briefingTagList.push(tempitem)
				})
				// console.log(this.briefingTagList)
				
				
			});
		},
		getUserBalance() {
			this.$api.getUserBalance({openid: getApp().globalData.openid}).then(res => {
				// console.log(res)
				this.userBalanc = parseFloat(res.data.UserPrice).toFixed(2)
				// console.log(moneyFormat(res.data.UserPrice, 2))
			})
		},
		modifyNegotiable(id) {
			this.$nextTick(() => {
				console.log(this.$refs)
			})

			this.isNegotiable = !this.isNegotiable;
			// 拼接参数是否面议
			this.infoParams['IsMianYi'] = this.isNegotiable
			// if(this.isNegotiable) {
			// 	this.infoParams['JiaGe'] = 0
			// } else {
				
			// }
		},
		riefingTagSelect(index) {
			let findIndex = this.selectHighlights.findIndex((value) => value.ID == this.briefingTagList[index].ID)
			this.briefingTagList[index].isSelect = !this.briefingTagList[index].isSelect
			if(findIndex == -1){
				this.selectHighlights.push(this.briefingTagList[index])
			}else{
				this.selectHighlights.splice(findIndex, 1).isSelect = false
			}
			if(this.selectHighlights.length > 4){
				this.selectHighlights.shift().isSelect = false
			}
			// console.log(this.selectHighlights)
			// 拼接参数
			let riefingTag = ''
			for(let item of this.selectHighlights) {
				riefingTag = riefingTag + item.Name + ','
			}
			this.infoParams['liangdian'] = riefingTag.substr(0,riefingTag.length -1)
		},
		async getLocation(){
			await uni.getLocation({
				type: 'gcj02',
				geocode: true,
				success: (res) => {
					this.longitude = res.longitude
					this.latitude = res.latitude
					this.getLocationAddress(this.latitude, this.longitude)
					// console.log(res);
				}
			})
		},
		async getLocationAddress(longitude, latitude) {
			let location = [longitude, latitude]
			let StringLocation = location.toString();
			// console.log(StringLocation)
			await this.$api.getLocationAddress({get_poi:1,key:this.$qqMapKey,location:StringLocation}).then(res => {
				// console.log(res)
				this.addressContent = res.result.formatted_addresses.recommend
			})
		},
		selectLocationAddress(){
			uni.chooseLocation({
				success:(res)=> {
					// console.log(res);
					this.addressContent = res.name + '(' + res.address + ')'
					this.longitude = res.longitude
					this.latitude = res.latitude
					// this.getRegionFn(res);
				},
				fail:()=>{
					// 如果用uni.chooseLocation没有获取到地理位置，则需要获取当前的授权信息，判断是否有地理授权信息
					uni.getSetting({
						success: (res) => {
							console.log(res);
							var status = res.authSetting;
							if(!status['scope.userLocation']){
							// 如果授权信息中没有地理位置的授权，则需要弹窗提示用户需要授权地理信息
								uni.showModal({
									title:"是否授权当前位置",
									content:"需要获取您的地理位置，请确认授权，否则地图功能将无法使用",
									success:(tip)=>{
										if(tip.confirm){
										// 如果用户同意授权地理信息，则打开授权设置页面，判断用户的操作
											uni.openSetting({
												success:(data)=>{
												// 如果用户授权了地理信息在，则提示授权成功
													if(data.authSetting['scope.userLocation']===true){
														uni.showToast({
															title:"授权成功",
															icon:"success",
															duration:1000
														})
														// 授权成功后，然后再次chooseLocation获取信息
														uni.chooseLocation({
															success: (res) => {
																// console.log("详细地址",res);
																this.addressContent = res.name + '(' + res.address + ')'
																this.longitude = res.longitude
																this.latitude = res.latitude
																// this.getRegionFn(res);
															}
														})
													}else{
														uni.showToast({
															title:"授权失败",
															icon:"none",
															duration:1000
														})
													}
												}
											})
										}
									}
								})
							}
						},
						fail: (res) => {
							uni.showToast({
								title:"调用授权窗口失败",
								icon:"none",
								duration:1000
							})
						}
					})
				}
			});
		},
		selectIsTopValue(evt) {
			this.isTopId = evt.detail.value
			for(let item of this.costList) {
				if(this.isTopId == item.ID){
					// 拼接支付ID
					this.infoParams['feeID'] = item.ID
					this.payments = parseFloat(item.Price).toFixed(2)
					console.log(parseFloat(item.Price).toFixed(2) == 0)
					if(parseFloat(item.Price).toFixed(2) == 0){
						this.isPayment = false
					} else {
						this.isPayment = true
					}
					break
				}
			}
		},
		selectTerms(e) {
			if(e.detail.value[0] === 'true') {
				this.isTerms = true
			} else {
				this.isTerms = false
			}
		},
		onKeyInput(e) {
			// 通过输入的内容拼接参数
			let unitsKey = e.target.id.split('_')
			// 拼接参数
			this.infoParams[this.unitsList[unitsKey[1]][unitsKey[0]]] = e.target.value
			// console.log(this.infoParams)
		},
		infoSubmit(){
			// this.infoParams = {}
			// console.log(this.selectList)
			// 选择型输入内容提示
			if(this.selectList.length > 0){
				if(this.selectList.length == 1){
					if(this.infoParams['xlid'] == 0){
						this.showMessage('warning', '请选择' + this.selectList[0].ClassName, 'center')
						this.isSubmit = false
						return
						// break
					} else {
						this.isSubmit = true
					}
				} else {
					for(let index in this.selectList){
						if(this.infoParams['xlid'+(parseInt(index)+1)] == 0){
							this.showMessage('warning', '请选择' + this.selectList[index].ClassName, 'center')
							this.isSubmit = false
							return
							// break
						} else {
							this.isSubmit = true
						}
					}
				}
			}

			// 输入型文本进行未输入提示
			if(this.inputList) {
				let warningMessage
				for(let val of this.inputList) {
					for(let key in val) {
						if(key != 'ID' && key != 'ClassName' && val[key] != '') {
							console.log(this.infoParams[this.unitsList['ID' + val.ID][key]])
							if(!this.infoParams[this.unitsList['ID' + val.ID][key]]){
								if(this.unitsList['ID' + val.ID][key] == 'JiaGe') {
									this.infoParams['IsMianYi'] = this.isNegotiable
									console.log(!this.isNegotiable)
									if(!this.isNegotiable) {
										console.log(this.infoParams[this.unitsList['ID' + val.ID][key]])
										if(this.infoParams[this.unitsList['ID' + val.ID][key]] == 0 || this.infoParams[this.unitsList['ID' + val.ID][key]] == '0'){
											warningMessage = '请输入正确的'+ val['ClassName']
											this.showMessage('warning', warningMessage, 'center')
											this.isSubmit = false
											return
										} else {
											warningMessage = '请输入'+ val['ClassName']
											this.showMessage('warning', warningMessage, 'center')
											this.isSubmit = false
											return
										}
									}
								} else {
									warningMessage = '请输入'+ val['ClassName']
									if(val['ClassName'] == '户型') {
										 warningMessage = '请完善'+ val['ClassName'] + '-' + val[key] +'的信息！'
									}
									this.showMessage('warning', warningMessage, 'center')
									this.isSubmit = false
									return
									// break
								}
							}
						}
					}
				}
			}
			
			//  在没有金额列表中是否只显示金额输入框
			if(this.isShowindependentPrice){
				console.log('在没有金额列表中是否只显示金额输入框，需要判断金额')
			} 
			
			if(this.infoContentDescribe.length <= 0) {
				this.showMessage('warning', '请输入具体描述内容！', 'center')
				this.isSubmit = false
				return
			} else {
				// 拼接参数
				this.infoParams['Content'] = this.infoContentDescribe
				this.isSubmit = true
			}
			if(this.contacts.length <= 0) {
				this.showMessage('warning', '请输入联系人信息！', 'center')
				this.isSubmit = false
				return
			} else {
				// 拼接参数
				this.infoParams['Person'] = this.contacts
				this.isSubmit = true
			}
			if(this.contactInfomation.length <= 0) {
				this.showMessage('warning', '请输入联系方式信息！', 'center')
				this.isSubmit = false
				return
			} else { 
				this.infoParams['Phone'] = this.contactInfomation
				this.isSubmit = true
			}
			if(!this.isTerms) {
				this.showMessage('warning', '请选择已经阅读发布条款！', 'center')
				this.isSubmit = false
				return
			} else {
				this.isSubmit = true
			}
			// 拼接参数支付方式
			this.infoParams['state_pay'] = this.paymentMethod
			// 拼接参数地址信息
			this.infoParams['Address'] = this.addressContent

			console.log(this.infoParams)
			
		},
		showMessage(type, title, direction){ //显示message
			this.$refs.message.show({
				type:type, //默认default
				msg:title, //显示内容
				icon:true, //显示icon
				mask:false, //遮罩
				time:3000, //显示时间
			    direction:direction, //方向
			})
			let id = this.$refs.message.id; //获取弹窗id,需要在弹出后获取
			setTimeout(()=>{
				this.$refs.message.close(id); //关闭某个弹窗
			},3000)
			// if(this.messageData.time===false){
			// 	if(this.messageData.mask){
			// 		this.$refs.message.show({
			// 			type:'warning',
			// 			msg:'注意!! 当前遮罩已开启,不可点击,为了方便测试这里设置了10秒后关闭当前消息,你也可以关闭指定某个消息,详情查看说明文档及demo.',
			// 			time:10000
			// 		}) 
			// 		setTimeout(()=>{
			// 			this.$refs.message.close(id); //关闭某个弹窗
			// 		},10000)
			// 	}
			// }
		},
		isShowPaySelectContent(){
			this.isShowPaySelect = !this.isShowPaySelect
		},
	},
	// app端拦截返回事件 ，仅app端生效
	onBackPress() {
		if (this.showRight || this.showLeft) {
			this.$refs.showLeft.close();
			this.$refs.showRight.close();
			return true;
		}
	},
	computed:{
		userBalanceText: function() {
			return moneyFormat(this.userBalanc, 2)
		},
		isShowPayMoneyDifference: function() {
			if(this.userBalanc < this.payments ) {
				return true
			} else {
				return false
			}
		},
		payPriceDifferenceText: function() {
			if(this.userBalanc < this.payments ) {
				return moneyFormat(this.payments-this.userBalanc, 2)
			}			
		}
	},
	components: {
		htzImageUpload,
		UniDrawer,
		QuickMessage,
	}
};
</script>

<style scoped>
@import url('submitForm.css');
</style>
